<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <link rel="stylesheet" href="/assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="/assets/css/common.css">
    <link rel="stylesheet" href="/assets/css/css.css">
    <title>订单列表</title>
</head>
<body>
    <section>
    	{if $orderInfo|@count >0}
        <table class="table table-bordered">
            <thead>
                <tr>
                    <td>操作</td>
                    <td>
                    		{if $orderInfo.status eq 0}
                        <!--  <button datafld="distribut" class="btn btn-warning modify-status" type="button">配货</button>-->
                        {/if}
                    </td>
                    <td>
                    	{if $orderInfo.status eq 0 ||  $orderInfo.status eq 2}
                        <button datafld="complete" class="btn btn-success modify-status" type="button">完成</button>
                        {/if}
                    </td>
                    <td>
                    		{if $orderInfo.status eq 0 ||  $orderInfo.status eq 2}
                        <!-- <button id="cancel" class="btn btn-danger" type="button">取消</button>-->
                        {/if}
                    </td>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td colspan="2"></td>
                </tr>
                <tr>
                    <td colspan="2">订单号</td>
                    <td colspan="2">{$orderInfo.order_num}</td>
                </tr>
                <tr>
                    <td colspan="2">收货人</td>
                    <td colspan="2">{$orderInfo.receiving}</td>
                </tr>
                <tr>
                    <td colspan="2">地址</td>
                    <td colspan="2">{$orderInfo.address}</td>
                </tr>
                <tr>
                    <td colspan="2">电话</td>
                    <td colspan="2">
                    	{if $orderInfo.phone neq ''}
                    		{$orderInfo.phone}
                    	{elseif $orderInfo.tel neq ''}
                    		{$orderInfo.tel}
                    	{/if}
                    </td>
                </tr>
                <tr>
                    <td colspan="2">送货时间</td>
                    <td colspan="2">{$orderInfo.deliver_time}</td>
                </tr>
                <tr>
                    <td colspan="2">下单时间</td>
                    <td colspan="2">{$orderInfo.order_time}</td>
                </tr>
                <tr>
                    <td colspan="2">备注</td>
                    <td colspan="2">{$orderInfo.remark}</td>
                </tr>
                <tr>
                    <td colspan="2">状态</td>
                    <td colspan="2">
                    		{if  $orderInfo.status eq 0}
                    			配货中
                    		{elseif $orderInfo.status eq 2}
                    			配送中
                    		{elseif $orderInfo.status eq 1}
                    			已完成
                    		{elseif $orderInfo.status eq 3}
                    			已取消
                    		{/if}
                    </td>
                </tr>
                <tr>
                    <td colspan="2">付款方式</td>
                    <td colspan="2">
                    		{if $orderInfo.cash_on_delivery eq 0}
                    			货到付款
                    		{elseif $orderInfo.cash_on_delivery eq 1}
                    			在线支付
                    		{/if}
                    </td>
                </tr>
                <tr>
                    <td colspan="2">支付明细</td>
                    <td colspan="2">
                        <table class="table table-bordered">
                            <tr>
                                <td>总金额</td>
                                <td>￥{$orderInfo.total}{if $orderInfo.delivery_fee gt 0 }(包含配送费：{$orderInfo.delivery_fee}){/if}</td>
                            </tr>
                            {foreach from=$payRecoder item=pay}
                            	<tr>
                                <td>
                                	{if $pay.pay_type eq 0}
                                		余额支付
                                	{elseif $pay.pay_type eq 1}
                                		微信支付
                                	{elseif $pay.pay_type eq 2}
                                		优惠券支付
                                	{/if}
                                </td>
                                <td>￥{$pay.money}</td>
                            </tr>
                            {/foreach}
                            <tr>
                                <td>还需支付</td>
                                <td>￥{$orderInfo.needPay}</td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <th>产品名称</th>
                    <th>数量</th>
                    <th>单价</th>
                    <th>总价</th>
                </tr>
                {foreach from=$orderProduct.products item=product}
                <tr>
                    <td>{$product.product_name}</td>
                    <td>{$product.product_num}</td>
                    <td>{$product.member_price}</td>
                    <td>{$product.total_member}</td>
                </tr>
                {/foreach}
                <tr>
                    <td colspan="4" align="center">客服电话：025-85263646</td>
                </tr>
            </tbody>
        </table>
        <input type="hidden" id="orderNum" name="order-num" value="{$orderInfo.order_num}" />
        {/if}
        <!--<div class="cancel-explain">
        		<textarea class="form-control" rows="3"></textarea>
        </div>-->
    </section>
    <script src="/assets/js/jquery-1.10.2.min.js"></script>
    <script src="/assets/js/bootstrap.min.js"></script>
    <script src="/assets/js/layer/layer.js"></script>
    <script src="/assets/js/public.js"></script>
    {literal}
    <script type="text/javascript">
		$(function(){
			
			$(".modify-status").click(function(){
				var order_num = $("#orderNum").val();
				var operation = $(this).attr("datafld")
				var data ={operation:operation , order_num:order_num};
				$.ajax({
					type:"patch",
					url:"/api/order/order",
					async:false,
					dataType:"json",
					data:data,
					success:function(data){
						if(data.success == true){
							alert(data.errorMessage);
							location.href = location.href;
							return false;
						}else{
							alert(data.errorMessage);
							return false;
						}
					}
				});
			});
			$("#cancel").click(function(){
				  layer.prompt({title: '请填写取消原因！', formType: 2}, function(text, index){
				    layer.close(index);
				    var order_num = $("#orderNum").val();
				    var data ={operation:'cancel' , order_num:order_num, remark:text};
					$.ajax({
						type:"patch",
						url:"/api/order/order",
						async:false,
						dataType:"json",
						data:data,
						success:function(data){
							if(data.success == true){
								alert(data.errorMessage);
								location.href = location.href;
								return false;
							}else{
								alert(data.errorMessage);
								return false;
							}
						}
					});
				  });				
			});
		});
    </script>
    {/literal}
</body>
</html>